import java.util.Scanner;

public class HJ5{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()){
            String str = sc.nextLine();
            int num = Integer.parseInt(str.substring(2),16);
            System.out.println(num);
        }
    }
}
